#!/usr/bin/python
# -*- coding:utf-8 -*-
# @FileName : DL6_test4_1.py
# Author    : myh

import torch
from d2l import torch as d2l
import torch.nn as nn
import torch.nn.functional as F


class Net(nn.Module):
    def init(self):
        super(Net, self).init()
        self.pool = nn.Conv2d(1, 1, 2)


    def forward(self, x):
        x = F.adaptive_max_pool2d(x, (2, 2))
        # 最大池化层
        return x

    def num_flat_features(self, x):
        size = x.size()[1:]
        num_features = 1
        for s in size:
            num_features *= s
        return num_features

net = Net()
X = torch.arange(16, dtype=torch.float32).reshape((1,1,4, 4)) # 必须是1144，而44报错？ 因为必须设置通道数嘛
print(X)
Y=net(X)
print(Y)